import store from '@/store/index'
// 根据屏幕大小字体自适应
const {documentElement: docEl} = document
const maxWidth = 1920
const baseWidth = 1499

export const setSize = () => {
  const clientWidth = docEl.clientWidth
  let rem = 16
  if (clientWidth >= maxWidth) rem = 16
  else {
    if (clientWidth <= maxWidth / 2) {
      rem = 12
    } else {
      rem = Math.max(rem * clientWidth / baseWidth, 12)
    }
  }
  docEl.style.fontSize = rem + 'px'
  store.commit('setRem', rem)
}